<?php

/**
 * Created by PhpStorm.
 * User: YUWENXUAN
 * Date: 2017/4/14
 * Time: 11:00
 */

//如果有var 定义，则被视为公有的
class access_control
{
    public $public = 'public';
    protected $protected = 'protected';   //受保护的
    private  $private = 'private';        //私有的
    var $var = 'var';

    function printHello(){
        echo $this->public.'<br>';
        echo $this->protected.'<br>';
        echo $this->private.'<br>';
        echo "printHello".'<br>';
    }

}

$obj = new access_control();
echo $obj->public.'<br>';
echo $obj->var.'<br>';
//echo $obj->protected.'<br>';   //Cannot access protected property 不能直接访问受保护的属性
//echo $obj->private.'<br>';     //Cannot access private property  不能访问私有属性
echo '<br>';
echo '<br>';
echo '<br>';
echo $obj->printHello();